<template>
	<!-- 添加弹框 -->
		<el-dialog  width="70%" title=""   visible :show-close="false" :modal-append-to-body="false" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
	    <div class="bt">{{vtitle}}</div>
		<el-form label-width="100px" class="form">
			<div class="top" style="width: 100%;float: left;">
			<div class="left" style="width: 50%;float: left;">
			<el-form-item label="课程名称">
				<el-input v-model="vfxkcidmc" placeholder="请选择分校课程 " class="select-block1"  icon="add":readonly="true"></el-input>
				<el-button size="small" @click="showwp()" class="select-block2" >选择</el-button>
			</el-form-item>
			<el-form-item label="班级名称" >
				<el-input v-model="vbjmc" placeholder="请输入班级名称" icon="add"  class="select-block1"></el-input>
				<el-button size="small" @click="bj" class="select-block2" >。。</el-button>
			</el-form-item>
			<el-form-item label="老师名称" >
				<el-select v-model="vlsid" placeholder="请选择老师" class="select-block1">
					<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist"></el-option>
				</el-select>
				<el-button type="" size="mini" @click="lskb()" icon="el-icon-question"></el-button>
			</el-form-item>

            </div>

            <div class="right" style="width: 50%;float: right;">
            <el-form-item label="行政老师" >
					<el-select v-model="xzls" placeholder="请选择行政老师" class="select-block1">
						<el-option :label="v.xslsmc" :value="v.xzlsid+''" v-for="v in xzlsList"></el-option>
					</el-select>
			</el-form-item>
			<el-form-item label="课时数量">
				<el-input v-model="vkssl" placeholder="请输入课时数量" icon="add" class="select-block1"></el-input>
			</el-form-item>
			<el-form-item label="开班日期">
				<el-date-picker  v-model="vbtime"  type="date" class="select-block1" placeholder="选择日期" @keyup.enter.native="search">  </el-date-picker>
			</el-form-item>
			</div>
			</div>
			<div class="ss" style="width: 100%;float: left;" >
			<el-form-item label="教室名称" style="float: left;width: 100%;">
				<el-select v-model="vjsid" class="select-block1" @change="getsjdlist">
			    <el-option :label="v.jsmc" :value="v.id " v-for="v in jsboxlist"></el-option>
				</el-select>
				<el-button type="" size="mini" @click="jskb()" icon="el-icon-question"></el-button>
				<el-button type="" size="mini" @click="jslskb()">检测</el-button>
			</el-form-item>
			<el-form-item label="上课安排"  v-if="this.vjsid!=''" style="margin-left: 0px;float: left;width: 100%;">
				<div class ="weekdiv" >
				<div class="wdiv0">
					<span v-for="city in sjdboxlist" >{{city.sjd}}<br/></span>
				</div>
				<div class="wdiv1">
					<el-checkbox-group v-model="vsjdid1">
						<el-checkbox v-for="city in sjdboxlist" :label="'1:'+city.id"   >一</el-checkbox><br/>
					</el-checkbox-group>
				</div>
				<div class="wdiv2">
					<el-checkbox-group v-model="vsjdid2">
						<el-checkbox v-for="city in sjdboxlist" :label="'2:'+city.id"   >二</el-checkbox><br/>
					</el-checkbox-group>
				</div>
				<div class="wdiv3">
						<el-checkbox-group v-model="vsjdid3">
						<el-checkbox v-for="city in sjdboxlist" :label="'3:'+city.id"   >三</el-checkbox><br/>
					</el-checkbox-group>
				</div>
				<div class="wdiv4">
						<el-checkbox-group v-model="vsjdid4">
						<el-checkbox v-for="city in sjdboxlist" :label="'4:'+city.id"   >四</el-checkbox><br/>
					</el-checkbox-group>
				</div>
				<div class="wdiv5">
						<el-checkbox-group v-model="vsjdid5">
						<el-checkbox v-for="city in sjdboxlist" :label="'5:'+city.id"   >五</el-checkbox><br/>
					</el-checkbox-group>
				</div>
				<div class="wdiv6">
						<el-checkbox-group v-model="vsjdid6">
						<el-checkbox v-for="city in sjdboxlist" :label="'6:'+city.id"   >六</el-checkbox><br/>
					</el-checkbox-group>
				</div>
				<div class="wdiv7">
						<el-checkbox-group v-model="vsjdid7">
						<el-checkbox v-for="city in sjdboxlist" :label="'0:'+city.id"   >七</el-checkbox><br/>
					</el-checkbox-group>
				</div>
				</div>
		</el-form-item>
		</div>
			<el-button type="primary" class="submit" @click="submit">保存</el-button>
			<el-button type="danger" class="submit" @click="cancel" style="margin-left: 10px;">退出</el-button>
		</el-form>

		<PayArticle class="wpfl1" @jcarticle="jcarticleed"  @close="jcarticlecancel" v-if="showarticle"></PayArticle>
		<Kschoose class="wpfl" @wpchoose="wpchooseed" @close="wpchoosecancel" v-if="showchoselist"></Kschoose>
		<!-- <el-dialog  width="60%" title=""    visible :show-close="true" :append-to-body="true"   :close-on-click-modal="false"> -->
			<Lskb class="lskb"  @close="lskbcancel" v-if="showlskblist" :params="vlsid"></Lskb>
			<Jskb class="lskb"  @close="jskbcancel" v-if="showjskblist" :params="vjsid"></Jskb>
			<Jslskb class="lskb"  @close="jslskbcancel" v-if="showjslskblist" :params="this.form"></Jslskb>

		<!-- </el-dialog> -->
	</el-dialog>
</template>
<script type="text/javascript">
	import Kschoose from '../../manage/kssz/kschoose'
	import Lskb from './kebiao/lskb'
	import Jskb from './kebiao/jskb'
	import PayArticle from './pay-articlejc'
	import Jslskb from './kebiao/jslskb'
	import qs from 'qs'
	export default {
		props: ['params'],
		components: { Kschoose, PayArticle, Lskb ,Jskb,Jslskb},
		data() {
			return {
				check:true,
				vbjlx:'N',
				vtitle:'班级新增',
				showchoselist: false,
				showlskblist: false,
				showjskblist: false,
				showarticle: false,
				showjslskblist:false,
				vfxkcid: '',
				vjsid:'',
				jsboxlist:[],
				sjdboxlist:[],
				vkssl:'',
				vsjdid1: [],
				vsjdid2: [],
				vsjdid3: [],
				vsjdid4: [],
				vsjdid5: [],
				vsjdid6: [],
				vsjdid7: [],
				vfxkcidmc: '',
				vbjmc: '',
				vbtime:'',
				vlsid: '',
				vcid: '',
				vjcid: '',
				vjcidmc: '',
				vlx: '',
				vypks: '',
				xzls:'',
				comboxlist: [],
				dialogTableVisible: true,
				xzlsList: [],
				ddd:[
					{id :1 ,
					ischecked :false
					}
				]
			}
		},
		created() {
			this.vbjlx =this.params.bjlx;
			if(this.vbjlx =='Y'){
				this.vtitle='班级新增';
			} else 	if(this.vbjlx =='N'){
				this.vtitle='预设班级新增';
			}
			this.getcomboxlist();
			this.getxzlsList();
			this.getjslist();
		},
		methods: {
			bj(){
				var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                      xxid:logininfo.xxid,
                      yhid:logininfo.id,
                      kcid:this.vfxkcid
               })
             //执行
                 this.axios.post(this.$store.state.api + 'bj/zdgetbjmc',  params2 )
                 .then(res => {
				console.log(res)
                this.vbjmc = res.data.data.list[0].bjmc;
                this.searchLoading = false;
                 }).catch(res => {
				})

			},
			jslskb(){
				this.showjslskblist = true;
			},
			jslskbcancel(setting) {

				this.showjslskblist = false;
			},
			getjslist(){
				var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                      keyword: this.vkeyword, // keyword
                      isenable: this.visenable,
                      yhid:logininfo.id,
                      xxid:logininfo.xxid,
                      pageindex: this.pageindex,
                      pagesize: this.pagesize
               })
             //执行
                 this.axios.post(this.$store.state.api + 'xxjs/mc',  params2 )
                 .then(res => {
                console.log(1)
							console.log(res)
							let data = res.data.data;
							this.jsboxlist = data;
                 }).catch(res => {
				})
			},
			getsjdlist(){
				var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                    jsid:this.vjsid
               })
             //执行
                 this.axios.post(this.$store.state.api + 'jssjd/mc',  params2 )
                 .then(res => {
                 let data = res.data.data;
							this.sjdboxlist = data;
                 }).catch(res => {
				})
			},
			getxzlsList () {
				var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                      yhid: logininfo.id,
							xxid:logininfo.xxid
               })
             //执行
                 this.axios.post(this.$store.state.api + 'ls/xzxzls',  params2 )
                 .then(res => {
                 console.log(res)
                  console.log(res)
							this.xzlsList = res.data.data;
                 }).catch(res => {
					 console.log(res)
				})
			},
			submit() {

				//检测
				var hstr='';
				// alert(arr.indexOf('4'))
				if (this.vsjdid1.length>0){
					hstr+= ',' + this.vsjdid1
				}
				if (this.vsjdid2.length>0){
					hstr+= ',' + this.vsjdid2
				}
				if (this.vsjdid3.length>0){
					hstr+= ',' + this.vsjdid3
				}
				if (this.vsjdid4.length>0){
					hstr+=',' +  this.vsjdid4
				}
				if (this.vsjdid5.length>0){
					hstr+= ',' + this.vsjdid5
				}
				if (this.vsjdid6.length>0){
					hstr+= ',' + this.vsjdid6
				}
				if (this.vsjdid7.length>0){
					hstr+= ',' + this.vsjdid7
				}
				this.$store.state.loading = true;
				if(!this.vbjmc) {
					this.$message.warning('请输入班级名称');
					this.$store.state.loading = false;
					return;
				}
				if(!this.vfxkcidmc) {
					this.$message.warning('请选择课程');
					this.$store.state.loading = false;
					return;
				}
				if(!this.vjcidmc) {
					this.$message.warning('请选择教材');
					this.$store.state.loading = false;
					return;
				}
				if(!this.vlsid) {
					this.$message.warning('请选择老师');
					this.$store.state.loading = false;
					return;
				}
				if(!this.xzls) {
					this.$message.warning('请选择行政老师');
					this.$store.state.loading = false;
					return;
				}
				if(!this.xzls) {
					this.$message.warning('请输入课时数量');
					this.$store.state.loading = false;
					return;
				}
				if(!this.vjsid) {
					this.$message.warning('请选择教室');
					this.$store.state.loading = false;
					return;
				}
				if(!this.vbtime) {
					this.$message.warning('请选择开班时间	');
					this.$store.state.loading = false;
					return;
				}
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					bjmc:this.vbjmc,
					xzid:this.xzls,
					kcid: this.vfxkcid,
					lsid: this.vlsid,
					yjkbrq:time1,
					jcid: this.vjcid,
					jsid:this.vjsid,
					sjdid:hstr,
					cid:this.vcid,
					ifys:this.vbjlx,
					kscnt:this.vkssl,
					yhid: logininfo.id,
					xxid: logininfo.xxid,

				});
				//执行
				this.axios.post(this.$store.state.api + 'ysbj/ysbjpk', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.showjslskblist = true;
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					})
			},
			lskb(){
				this.showlskblist = true;
			},
			jskb(){
				this.showjskblist = true;
			},
			showwp() {
				this.showchoselist = true;
			},
			showjc() {
				this.showarticle = true;
			},
			wpchooseed(josndata) {
				console.log(josndata,'wzwZ');
				this.vfxkcidmc = josndata.kcmc;
				this.vfxkcid = josndata.fxkcid;
				this.vkssl=josndata.kssl;

				this.showchoselist = false;
			},
			jcarticleed(josndata) {
			    this.vcid = josndata.cid;
			    this.vjcid = josndata.jcid;
			    this.vjcidmc = josndata.jcidmc;
				this.showarticle = false;
			},
			wpchoosecancel(setting) {
				// console.log()
				if(setting.cancel == false){
					this.vfxkcid = setting.data[0].id;
					this.vfxkcidmc = setting.data[0].mc;
					this.vjcidmc = setting.data[0].cmc;
					this.vjcid = setting.data[0].jcid;
					this.vcid = setting.data[0].cid;
					this.vkssl = setting.data[0].number;
				}
				this.showchoselist = false;
			},
			lskbcancel(setting) {
				// alert(11)
				// console.log()
				// if(setting.cancel == false){
				// 	this.vfxkcid = setting.data[0].id;
				// 	this.vfxkcidmc = setting.data[0].mc;
				// 	this.vkssl = setting.data[0].number;
				// }
				this.showlskblist = false;
			},
			jskbcancel(setting) {
				// alert(11)
				// console.log()
				// if(setting.cancel == false){
				// 	this.vfxkcid = setting.data[0].id;
				// 	this.vfxkcidmc = setting.data[0].mc;
				// 	this.vkssl = setting.data[0].number;
				// }
				this.showjskblist = false;
			},
			jcarticlecancel() {
				this.showarticle = false;
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			},
			getcomboxlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                     yhid: logininfo.id,
						xxid: logininfo.xxid
               })
             //执行
                 this.axios.post(this.$store.state.api + 'ls/getlslist',  params2 )
                 .then(res => {
					let data = res.data.data;
					let list = data.list;
					this.comboxlist = list;
                 }).catch(res => {
                  this.searchLoading = false;
				})
			}
		}
	}
</script>
<style lang="less" scoped >
	.wrap {
		.row{
			height:50px;
			line-height: 50px;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.close{
				z-index: 10;
				position: absolute;
		}
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.input {
			width:280px;
			display: inline-block;
			margin-left: 10px;
		}
		.input1 {
			width: 210px;
			display: inline-block;
			margin-left: 10px;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.submit {
			width: 120px;
			margin-left: 35%;
		}
		.wpfl {
			// background: red;
			// position: absolute;
			// top: 20%;
			// left: -10%;
		}
		.lskb {
			width: 143.5%;
			background: #fff;
			position: absolute;
			top: -100px;
			left: -22%;
			z-index: 50;
			padding-bottom: 100px;
		}
		.wpfl1 {
			width: 130%;
			background: #fff;
			position: absolute;
			top: 5px;
			left: -66px;
		}
		.form {
			overflow: hidden;
			text-align: left;
			margin-top: 20px;
			.select-block {
				width: 85%;
				display: block;
			}
			.select-block1 {
				width: 68%;
				// display: block;
			}
			.weekdiv{
				width: 100%;
				height: 100%;
				margin: 0 auto;
				background: lightblue;


			}
			.wdiv0 {
				line-height: 45px;
				width: 100px;
				margin-left: 20%;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv1 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv2 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv3 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv4 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv5 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv6 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv7 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.el-checkbox+.el-checkbox {
     margin-left: 0px;
}
		}


	}

</style>
